package com.ityedao.IO转换流.字节输出转换流;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

public class OutputStreamWriterTest {
    public static void main(String[] args) {
        try (
                // 1、创建一个文件字节输出流
                OutputStream os = new FileOutputStream("src/ityedao-指定字符集.txt");
                // 2、把原始的字节输出流按照指定的字符集转换成字符输出流
                OutputStreamWriter osw = new OutputStreamWriter(os, "GBK");
                // 3、把字符输出流包装成缓冲字符输出流
                BufferedWriter bfw = new BufferedWriter(osw);
        ) {
            bfw.write("我爱你中国abd");
            bfw.write("12帮你zu");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
